
package com.scs.application.modules.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.modules.base.entity.CertificateRequirement;
import com.scs.application.modules.base.mapper.CertificateRequirementMapper;
import com.scs.application.modules.base.request.CertificateRequirementQueryRequest;
import com.scs.application.modules.base.service.CertificateRequirementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 医院资质要求 service 实现
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class CertificateRequirementServiceImpl extends BaseServiceImpl<CertificateRequirementMapper, CertificateRequirement> implements CertificateRequirementService {

    @Override
    public List<CertificateRequirement> list(CertificateRequirementQueryRequest request) {
        List<CertificateRequirement> list = this.list(getQueryWrapper(request));
        return list;
    }

    @Override
    public IPage<CertificateRequirement> page(CertificateRequirementQueryRequest request) {
        IPage page = this.page(request.getPage(), getQueryWrapper(request));
        return page;
    }

    private QueryWrapper<CertificateRequirement> getQueryWrapper(CertificateRequirementQueryRequest request) {
        return Wrappers.<CertificateRequirement>query()
                .orderByDesc("gmt_modified");
    }
}
